import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, ILab } from "./types";

/* 查询实验室列表 */
export function getPageLabAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<ILab[]>> {
  return request({
    url: "/laboratory/page",
    method: "get",
    params: queryParams,
  });
}

/* 查询实验室列表 */
export function getListLabAPI(): AxiosPromise<ILab[]> {
  return request({
    url: "/laboratory/list",
    method: "get",
  });
}

/* 根据id查询实验室对象 */
export function getFormLabAPI(id: number): AxiosPromise<ILab> {
  return request({
    url: `/laboratory/${id}/form`,
    method: "get",
  });
}

/**
 * 添加实验室
 *
 * @param data
 */
export function addLabAPI(data: any) {
  return request({
    url: "/laboratory",
    method: "post",
    data: data,
  });
}

/**
 * 修改实验室
 *
 * @param id
 * @param data
 */
export function updateLabAPI(id: number, data: ILab) {
  return request({
    url: "/laboratory/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除实验室
 *
 * @param ids
 */
export function deleteLabAPI(ids: number) {
  return request({
    url: "/laboratory/" + ids,
    method: "delete",
  });
}
